package org.training.apr.model.utils.builder;

import org.training.apr.model.Role;
import org.training.apr.model.User;
import org.training.apr.security.FakeSecurityContext;


public abstract class Builder {
	private static final User superuser = new UserBuilder().withRole(new RoleBuilder().withType(Role.FINANCIAL_DIRECTOR).build()).build();
	
	protected Long id = IdGenerator.nextId();
	
	private User savedUser = null;
	
	protected void superuser() {
		FakeSecurityContext app = FakeSecurityContext.getInstance();
		savedUser = app.getUser();
		app.setUser(superuser);
	}
	
	protected void restoreUser() {
		FakeSecurityContext.getInstance().setUser(savedUser);
	}
}
